package ooday03;

public class Test {
    public static void main(String[] args) {
        Dog[] dogs=new Dog[3];//创建一个引用类型数组dogs，含有三个元素
        //给引用类型数组的元素赋值
        dogs[0]=new Dog("小黑",2,"黑");
        dogs[1]=new Dog("小灰",1,"灰");
        dogs[2]=new Dog("小黄",3,"黄");
        System.out.println(dogs[0].name);//输出第1只狗狗的名字
        dogs[1].age=4;//修改第2个狗狗的年龄为4岁
        dogs[2].swim();//第3只狗狗在游泳
        for (int i=0;i<dogs.length;i++){//遍历dogs数组
            System.out.println(dogs[i].name);//输出每只狗狗的名字
            dogs[i].eat();//每只狗狗吃饭
        }

        Chick[] chicks=new Chick[4];//创建一个引用类型数组chicks，含4有个元素
        //给引用类型数组的元素赋值
        chicks[0]=new Chick("小红",1,"红");
        chicks[1]=new Chick("小黄",2,"黄");
        chicks[2]=new Chick("小白",3,"白");
        chicks[3]=new Chick("小青",4,"青");
        System.out.println(chicks[0].name);//输出第1只小鸡的名字
        dogs[1].age=5;
        for (int i=0;i<chicks.length;i++){//遍历chicks数组
            System.out.println(chicks[i].name);
            chicks[i].drink();
        }

        Fish[] fishs=new Fish[2];//创建一个引用类型数组fishs，含有2个元素
        fishs[0]=new Fish("小金",1,"金");
        fishs[1]=new Fish("小红",2,"红");
        System.out.println(fishs[0].name);
        fishs[1].age=5;
        for (int i=0;i<fishs.length;i++){//遍历fishs数组
            System.out.println(fishs[i].name);
            fishs[i].drink();
        }
    }
}
